package edu.krazy.engine;

import java.util.Iterator;

import edu.krazy.client.BasicClient;
import edu.krazy.client.IOnKrazyListener;
import edu.krazy.client.KrazyKartsMain;
import edu.krazy.client.KrazyModel;

public class KrazyKarts implements IOnKrazyListener {

	private KrazyKartsMain mConnClient;
	private BasicClient myClient;
	
	public KrazyKarts(){
		mConnClient = new KrazyKartsMain(this);
		
	}
	
	//@Override
	public void onReadyGameEngine(BasicClient client) {
		myClient = client;
		System.out.println("on readyGameEngine");
	}

	//@Override
	public void onStartGameEngine(KrazyModel model) {
		// TODO Auto-generated method stub
		
		int n_players = model.getPositions().size();
		//model.getPositions().keySet().
		int player_number = 1;
		String my_username = myClient.getUsername();
		for(Iterator it = model.getPositions().keySet().iterator(); it.hasNext();)
		{
			Object key = it.next();
			//System.out.println("key is "+key.toString());
			if(key.equals(my_username))
			{
				System.out.println("my player number is "+player_number);
				Renderer gameEngine = new Renderer(player_number,n_players,myClient,model,my_username);
				
				break;
				
			}
			player_number++;
			
		}
		//System.out.println("model "+model.getPositions().get(key).toString());
		
		
		
		
	}
	
	public static void main(String[] args) {
		new KrazyKarts();
	}

}
